import request from "@/utils/request";

import type { ITrademarkList, ITrademark } from "./model"; // 返回数据的接口

// 请求接口
enum API {
  TRADEMARKLIST = "/admin/product/baseTrademark/", // 获取分页列表的接口
  ADDTRADEMARK = "/admin/product/baseTrademark/save", // 添加品牌的接口
  UPDATETRADEMARK = "/admin/product/baseTrademark/update", // 修改品牌的接口
  DELETETRADEMARK = "/admin/product/baseTrademark/remove/", // 删除品牌的接口
}

// 分页列表数据
export const reqTrademarkList = (page: number, limit: number) =>
  request.get<any, ITrademarkList>(API.TRADEMARKLIST + `${page}/${limit}`);

// 添加或修改品牌数据
export const reqAddOrUpdateTrademark = (data: ITrademark) => {
  if (data.id) {
    return request.put<any, any>(API.UPDATETRADEMARK, data);
  } else {
    return request.post<any, any>(API.ADDTRADEMARK, data);
  }
};

// 删除品牌
export const reqDeleteTrademark = (id: number | undefined) =>
  request.delete<any, any>(API.DELETETRADEMARK + id);
